<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // 打印倒三角形
        var star = '';
        for (var i = 1; i <= 10; i++) {
            for (var j = i; j <= 10; j++) {
                star = star + '*';
            }
            
            star = star + '\n';
        }
        console.log(star);
        alert(star);
         // 打印9*9的正三角
        var star = '';
        for (var i = 0; i < 9; i++) {        //行数
            for (var j = 0; j < i; j++) {   //每行个数
                star = star + '*';
            }
            star = star + '\n';
        }
        alert(star);
        console.log(star);


    </script>
</body>

</html>